package main.java.dal.valueobject;

import java.util.LinkedList;
import java.util.List;

public class GroupVO extends ValueObject {
    String description;
    List<RoleVO> roles;
    
    public GroupVO(long id, String name, String description) {
	super(id, name);
	this.description = description;
	roles = new LinkedList<RoleVO>();
    }
    
    public void setRoles(List<RoleVO> roles) {
	this.roles = roles;
    }
    
    public List<RoleVO> getRoles() {
	return roles;
    }
    
    /**
     * @return the description
     */
    public String getDescription() {
	return description;
    }
    
    /**
     * @param description
     *            the description to set
     */
    public void setDescription(String description) {
	this.description = description;
    }
    

    
    /*
     * (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
	final int prime = 31;
	int result = super.hashCode();
	result = prime * result
		+ ((description == null) ? 0 : description.hashCode());
	result = prime * result + ((roles == null) ? 0 : roles.hashCode());
	return result;
    }
    
    /*
     * (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
	if (this == obj) {
	    return true;
	}
	if (!super.equals(obj)) {
	    return false;
	}
	if (!(obj instanceof GroupVO)) {
	    return false;
	}
	GroupVO other = (GroupVO) obj;
	if (description == null) {
	    if (other.description != null) {
		return false;
	    }
	} else if (!description.equals(other.description)) {
	    return false;
	}
	if (roles == null) {
	    if (other.roles != null) {
		return false;
	    }
	} else if (!roles.equals(other.roles)) {
	    return false;
	}
	return true;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
	return String.format("GroupVO [description=%s, roles=%s]", description,
		roles);
    }
    
}
